package com.kaibes.imserver.model;

import org.json.JSONObject;

public class GetColumnsValues {
	private String[] columns;
	private String[] values;
	private JSONObject jsonObject;
	private int i = 0;

	public GetColumnsValues(JSONObject jsonObject) {
		columns = new String[jsonObject.length()];
		values = new String[jsonObject.length()];
		this.jsonObject = jsonObject;

		doit("nickname");
		doit("sex");
		doit("birth");
		doit("job");
		doit("company");
		doit("school");
		doit("address");
		doit("hometown");
		doit("email");
		doit("introduction");
		doit("signature");
	}

	private void doit(String key) {
		if (jsonObject.has(key)) {
			columns[i] = key;
			values[i] = jsonObject.getString(key);
			i++;
		}
	}

	public String[] getColumns() {
		return columns;
	}

	public String[] getValues() {
		return values;
	}

	public int size() {
		return i;
	}
}
